<?php
/**
 * Created by PhpStorm.
 * User: Yieong
 * Date: 14/10/21
 * Time: 上午9:26
 */

class PubGrid extends LibGrid {

    protected $showType = 'tab';

    public function setShowType($type){
        if(in_array($type, array('tab', 'float','line'))){
            $this->showType = $type;
        }
    }

    public function show(){
        return array(
            'type' => $this->showType,
            'main' => $this->grid
        );
    }

    public function getExportHeader($header){
        $newHeader = array();
        foreach($header as $k=>$v){
            if(isset($v['include'])){
                $text = $v['text'];

                foreach($v['include'] as $kk=>$vv){
                    $newHeader[$kk] = "{$text}-{$vv['text']}";
                }
            }else{
                $newHeader[$k] = $v['text'];
            }
        }
        return $newHeader;
    }

    public function addLink($value, $name, $to=false){
        $this->grid[] = array(
            'value'  => $value,
            'name'   => $name,
            'to'     => $to
        );
    }

}